<script src="/include/calendar/calendar.js"></script>
<div class="pageheader">
	<h2>
		<i class="fa fa-sitemap"></i>办公管理
	</h2>
	<div class="breadcrumb-wrapper">
		<span class="label">你所在的位置：</span>
		<ol class="breadcrumb">
			<li><a href="/index">ERP管理系统</a></li>
			<li>办公管理</li>
			<li class="active">我的任务</li>
		</ol>
	</div>
</div>
<div class="contentpanel">
	<div class="main">
		<form id="search-form" class="form-inline" method="post" style="margin-bottom: 10px;">
			<div class="form-group">
				<input placeholder="标题" type="text" name="title" value="<?php echo $this->title;?>" class="form-control">
			</div>
			<!-- <div class="form-group"> 
				<input placeholder="指派给" type="text" name="task_id" value="<?php echo $this->task_id;?>" class="form-control">
			</div> -->
			<div class="form-group">
				<!-- <label for="Statu">状态</label>  -->
				<select class='form-control' name='statu'>
					<option value=''
						<?php if($this->statu == ''){echo 'selected="selected"';}?>>选择状态</option>
					<option value='0'
						<?php if($this->statu == '0'){echo 'selected="selected"';}?>>未开始</option>
					<option value='1'
						<?php if($this->statu == '1'){echo 'selected="selected"';}?>>进行中</option>
					<option value='2'
						<?php if($this->statu == '2'){echo 'selected="selected"';}?>>已完成</option>
				</select>
			</div>
            <div class="form-group">
                <label for="date">日期:</label>
                <input class="form-control" type="text" name="starttime" onclick="new Calendar().show(this);" readonly="readonly" value="<?php echo $this->starttime;?>">
	                       至<input class="form-control" type="text" name="endtime" onclick="new Calendar().show(this);" readonly="readonly" value="<?php echo $this->endtime;?>">
            </div>
			<button type="submit" class="btn btn-primary">搜索</button>
		</form>
		<table id="order-log" class="table table-bordered table-hover">
			<thead>
				<tr>
					<th width="20%">摘要</th>
					<th>网站</th>
					<th>指派给</th>
					<th width="5%">指派时间</th>
					<th>优先级</th>
					<th>工时</th>
					<th>进度</th>
					<th>状态</th>
					<th>评价</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
                <?php if ($this->list):?>
                <?php foreach ($this->list as $v):?>
                <tr>
					<td><?php echo $v['title'];?></td>
					<td><?php echo $v['site'];?></td>
					<td><?php echo $v['task_name'];?></td>
					<td><?php echo $v['add_time'];?></td>
					<td><?php echo $v['priority']==0 ? '默认等待':($v['priority']==1 ? '比较重要':'十分紧急');?></td>
					<td><?php echo '已用'.$v['time'].'个工时';?></td>
					<td><?php echo $v['progress'].'%';?></td>
					<td>
					    <?php 
					    if(intval($v['statu'])==0){
					    	echo '<span class="label label-warning">未开始</span>';
					    }else if(intval($v['statu'])==1){
					    	echo '<span class="label label-primary">进行中</span>';
					    }else{
					    	echo '<span class="label label-success">已完成</span>';
					    }?>
					</td>
					<td><?php echo empty($v['evaluate'])?'<span class="label label-warning">未评价</span>':'<span class="label label-success">已评价</span>'; ?></td>
					<td>
				        <a class="btn btn-default btn-sm" title="查看需求" href="javascript:void(0);" onclick="view(<?php echo $v['id']; ?>)">查看</a> 
				        <a class="btn btn-default btn-sm" title="修改需求" target="_blank" href="/office/updateneed?id=<?php echo $v['id'];?>">修改</a> 
				        <a class="btn btn-default btn-sm" title="评价任务" href="/office/evaluate?id=<?php echo $v['id'];?>">评价</a>
				        <a class="btn btn-default btn-sm" title="删除需求" href="javascript:void(0);" onclick="deleteNeed(<?php echo $v['id']; ?>, this)">删除</a>
					</td>
				</tr>
			    <?php endforeach;?> 
			    <?php endif;?>
			    <tr>
					<td colspan="7">
			            <?php echo $this->paginationControl ( $this->paginator, 'Sliding', 'page/qaitem.phtml', array (
			            		'title' => $this->title,
					     	    'statu'=>$this->statu,
						        'starttime' => $this->starttime,
						        'endtime' => $this->endtime) 
			            );?>
			        </td>
				</tr>
			</tbody>
		</table>
	</div>
</div>
<div class="modal" tabindex="-1" style="display: none;">
    <div class="modal-dialog">
        <div class="modal-content">
            
        </div>
   </div>
</div>
<div class="in"></div>
<script type="text/javascript">
$(document).ready(function(){
	$(".modal-header .close").live('click',function(){
		$(".modal").hide();
		$(".in").removeClass("modal-backdrop");
	});
});
function deleteNeed(id, obj) {
    if (confirm('确认删除?')) {
	    $.ajax({
		    type: "get",
		    url: "/office/deleteqaitem?id="+id,
		    data: {},
		    success: function(data) {
			    switch(data) {
			    case "1":
				    alert('删除成功');
				    $(obj).parent().parent().remove();
				    break;
				default:
					alert('删除失败');
	            }
	         }			
        });
    }
}
function view(id) {
	$.get("/office/viewqaitem", {id:id},
	    function(data){
	        $('.modal-content').html(data.html);
	        $(".modal").show();
		    $(".in").addClass("modal-backdrop");
		},'json'
	);
}
</script>